Skip to content

Conversation

@agarwal-navin
Copy link
Contributor

@agarwal-navin agarwal-navin commented Oct 10, 2025

Description

Each layer within a client (Loader, Driver, Runtime and Datastore) has a generation property which should be incremented monthly. It provides a simple way to determine if two layers are compatible with each other by comparing their generations since layer compatibility is expressed in number of months. For example, between the Runtime and Datastore layers, we support a 3 months compatibility. So, they are compatible if the difference in their generation is <3. See #22877 for more details on how this will work.

This change adds an automated way to increment the generation of these layers for simplicity and consistency. Here is how it works:

  • A new PackageCommand called UpdateGenerationCommand is added. The flub command flub generate:layerGeneration can be run this command for a package.
  • The command expects that a file called layerGenerationState.ts should exist at the src folder under a package directory.
  • The layerGenerationState.ts file will be auto generated and contain the last release version, the last release date and the generation as per the last release.
  • On running flub generate:layerGeneration for a package, it will read the contents of its layerGenerationState.ts file, and update the generation (if needed) as follows:
    • If the package version has changed, i.e., a new release has happened, it will update the generation to New generation = Old generation + no. of months since last release.
    • An important requirement is that in between two subsequent releases, the generation should not be incremented by more than the minimum compat window between 2 layers across all layers boundaries. For example, say compat window between Loader / Runtime is 12 months but between Runtime / Datastore it is only 3 months. Then between 2 subsequent releases, generation should not increment by more than 2. If that happens, it doesn't give customers enough time to upgrade their packages and saturate a release before upgrading to the next one. Layer compatiility will break as soon they upgrade.
    • So, the logic for new generation is updated to: New generation = Old generation + min (no. of months since last release, min. compat window between layers across all layer boundaries).
  • The flub generate:layerGeneration command will be added to the scripts in client-utils's package.json file in a subsequent PR. The generation information for all the layers will be present in this package. The associated chagnes to the build system to run this command on releases will also be added in a subsequent PR.

AB#51926

@github-actions github-actions bot added area: build Build related issues base: main PRs targeted against main branch labels Oct 10, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds automated layer generation updates to the FluidFramework release process. The layer generation system provides compatibility tracking between different client layers (Loader, Driver, Runtime, Datastore) by incrementing a generation number monthly.

  • Adds automated generation update logic during minor/major releases
  • Creates auto-generated layerGeneration.ts file to track current generation and release date
  • Implements logic to calculate new generation based on months elapsed with compatibility window constraints

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
FluidRelease.fsl Adds DoLayerGenerationUpdate step to release workflow after DoReleaseGroupBump
fluidReleaseStateHandler.ts Registers the new doLayerGenerationUpdate handler in the state machine
doFunctions.ts Implements the core layer generation update logic with file I/O and date calculations

(today.getTime() - previousReleaseDate.getTime()) / (1000 * 60 * 60 * 24),
);

const monthsBetweenReleases = Math.floor(daysBetweenReleases / 30);
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a fixed 30-day month approximation is inaccurate for month calculations. Consider using date arithmetic that accounts for actual month boundaries, such as calculating the difference in months and years between the two dates.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just use 100 days for 3 months, 200 for six months, and 400 for 12 months, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to 33 days instead to 30. That should give a couple of days of buffer over the max of 31. let me know what you think.

Comment on lines 246 to 248
const match = fileContents.match(
/.*\nexport const generation = (\d+);[\n\r]*export const releaseDate = "((0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2})";.*/m,
);
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern is complex and fragile. Consider parsing the TypeScript file using a proper parser or extracting the values using a more robust approach that doesn't rely on exact formatting.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we control the packages, consider putting the date and time of release in the package itself then we can just read it from the previous version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean in the package.json?

@agarwal-navin agarwal-navin changed the title (layer compat) All logic to auto update layer compat generation during release (compat) All logic to auto update layer compat generation during release Oct 10, 2025
@agarwal-navin agarwal-navin changed the title (compat) All logic to auto update layer compat generation during release (compat) Add logic to auto update layer compat generation during release Oct 13, 2025
@agarwal-navin agarwal-navin changed the title (compat) Add logic to auto update layer compat generation during release (compat) Add PackageCommand to auto update layer compat generation Oct 30, 2025
@agarwal-navin agarwal-navin changed the title (compat) Add PackageCommand to auto update layer compat generation (compat) Add PackageCommand to auto update layer compatibility generation Oct 30, 2025
Copy link
Contributor

@scottn12 scottn12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build related issues base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants